#include <iostream>
#include <stdlib.h>
#include <cmath>
int c[10005][3];
int main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int T, m, _n, L, V, ans = 0, t;
	std::cin >> T;
	for(int i = 0; i < T; i++){
		std::cin >> _n >> m >> L >> V;
		for(int k = 0; k < _n;k++){
			std::cin >> c[k][0] >> c[k][1] >> c[k][2];
		}
		for(int k = 0; k < m;k++){
			std::cin >> t;
		}
		for(int k = 0; k < _n;k++){
			double tmp = c[k][1]*c[k][1] + 2*c[k][2]*(t - c[k][0]);
			if(c[k][2] > 0 ? tmp >= 0 && sqrt(tmp) > V : c[k][2] == 0 && c[k][1] > V){
				ans++;
			}
		}
		std::cout << ans << ' ' << m - 1 << '\n';
		ans = 0;
	}
	return 0;
}
/*
int c[10005] = {0}, d[10005];
bool sa[10005] = {0};
double n[10005];
double half1(int start, int len, int org, int add, int lim){//add!=0
	double l = start, r = len, mid = (l + r) /2;
	while(r - l <= 0.1){
		double t = org*org + 2*add*(mid - l);
		if(t >= 0 && sqrt(t) > lim){
			if(add > 0){
				r= mid;
			}
			else{
				l = mid + 0.5;
			}
		}
		else{
			if(add > 0){
				l = mid + 0.5;
			}
			else{
				r= mid;
			}
		}
		mid = (l + r) /2;
	}
	return (l+r)/2;
}

bool half2(double s, double e, int n){
	int l = 0, r = n, mid = (l + r) /2;
	while(r > l){
		if(c[mid] >= s && c[mid] <= e){
			return 1;
		}
		else{
			if(c[mid] > e){
				r= mid;
			}
			else{
				l = mid + 1;
			}
		}
		mid = (l + r) /2;
	}
	return 0;
}

int main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int T, m, _n, L, V, v, a, ans = 0;
	std::cin >> T;
	for(int i = 0; i < T; i++){
		std::cin >> _n >> m >> L >> V;
		for(int k = 0; k < _n;k++){
			std::cin >> d[k] >> v >> a;
			if(a!=0){
				sa[k] = a > 0;
				n[k] = half1(d[k], L, v, a, V);
			}
			else{
				if(v<=V){
					n[k] = L + 1;
				}
				else{
					n[k] = 0;
				}
			}
			std::cerr << 'a';
		}
		for(int k = 0; k < m;k++){
			std::cin >> c[i];
		}
		for(int k = 0; k < _n;k++){
			if(n[k] == L + 1) {
				continue;
			}
			if(sa[k]){
				ans += half2(n[k], L, m);
			}
			else{
				ans += half2(d[k], n[k], m);
			}
			std::cerr << 'b';
		}
		std::cout << ans << '\n';
		ans = 0;
	}
	return 0;
}
*/
